package it.getta.vicinometro.popup;

import it.getta.vicinometro.ActivityCallBack;
import it.getta.vicinometro.R;
import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class ProgressPopup extends VicinometroPopup {
	
	private boolean mIsLoading;

	public ProgressPopup(Context context, ActivityCallBack activityCallBack) {
		super(context, activityCallBack, R.layout.progress_popup);
		
		setOnDismissListener(new OnDismissListener() {
			@Override
			public void onDismiss() {
				setLoading(false);
			} 
		});
		
//		mPopupRootView.setOnKeyListener(new OnKeyListener() {
//			
//			@Override
//			public boolean onKey(View v, int keyCode, KeyEvent event) {
//				
//			}
//		});
	}

	@Override
	public void showPopup() {
		super.showPopup();
		setLoading(true);
		setTouchable(false);
		setOutsideTouchable(false);
		setTouchInterceptor(new OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				return true;
			}

		});
		show(mActivityCallBack.getPopupAnchor()); 
		
	}

	public boolean isLoading() {
		return mIsLoading;
	}

	public void setLoading(boolean isLoading) {
		this.mIsLoading = isLoading;
	}

}
